<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>Zend_Service_Simpy - Zend Framework Manual</title>

    <link href="../css/shCore.css" rel="stylesheet" type="text/css" />
    <link href="../css/shThemeDefault.css" rel="stylesheet" type="text/css" />
    <link href="../css/styles.css" media="all" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Zend Framework</h1>
<h2>Programmer's Reference Guide</h2>
<ul>
    <li><a href="../en/zend.service.simpy.html">Inglês (English)</a></li>
    <li><a href="../pt-br/zend.service.simpy.html">Português Brasileiro (Brazilian Portuguese)</a></li>
</ul>
<table width="100%">
    <tr valign="top">
        <td width="85%">
            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.service.short-url.html">Zend_Service_ShortUrl</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.service.html">Zend_Service</a></span><br />
                        <span class="home"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.service.slideshare.html">Zend_Service_SlideShare</a></div>
                    </td>
                </tr>
            </table>
<hr />
<div id="zend.service.simpy" class="section"><div class="info"><h1 class="title">Zend_Service_Simpy</h1></div>
    

    <div class="section" id="zend.service.simpy.introduction"><div class="info"><h1 class="title">Introduction</h1></div>
        

        <p class="para">
            <span class="classname">Zend_Service_Simpy</span> is a lightweight wrapper for the free REST
            <acronym class="acronym">API</acronym> available for the Simpy social bookmarking service.
        </p>

        <p class="para">
            In order to use <span class="classname">Zend_Service_Simpy</span>, you should already have a
            Simpy account. To get an account, visit the <a href="http://simpy.com" class="link external">&raquo; Simpy web site</a>. For more information on the Simpy
            REST <acronym class="acronym">API</acronym>, refer to the <a href="http://www.simpy.com/doc/api/rest" class="link external">&raquo; Simpy REST <acronym class="acronym">API</acronym>
                documentation</a>.
        </p>

        <p class="para">
            The Simpy REST <acronym class="acronym">API</acronym> allows developers to interact with specific
            aspects of the service that the Simpy web site offers. The sections following will
            outline the use of <span class="classname">Zend_Service_Simpy</span> for each of these areas.

            <ul class="itemizedlist">
                <li class="listitem">
                    <p class="para">
                        Links: Create, Retrieve, Update, Delete
                    </p>
                </li>

                <li class="listitem">
                    <p class="para">
                        Tags: Retrieve, Delete, Rename, Merge, Split
                    </p>
                </li>

                <li class="listitem">
                    <p class="para">
                        Notes: Create, Retrieve, Update, Delete
                    </p>
                </li>

                <li class="listitem">
                    <p class="para">
                        Watchlists: Get, Get All
                    </p>
                </li>
            </ul>
        </p>
    </div>

    <div class="section" id="zend.service.simpy.links"><div class="info"><h1 class="title">Links</h1></div>
        

        <p class="para">
            When querying links, results are returned in descending order by date added. Links can
            be searched by title, nickname, tags, note, or even the content of the web page
            associated with the link. Simpy offers searching by any or all of these fields with
            phrases, boolean operators, and wildcards. See the
            <a href="http://www.simpy.com/faq#searchSyntax" class="link external">&raquo; search syntax</a> and
            <a href="http://www.simpy.com/faq#searchFieldsLinks" class="link external">&raquo; search fields</a>
            sections of the Simpy FAQ for more information.
        </p>

        <div class="example" id="zend.service.simpy.links.querying"><div class="info"><p><b>Example #1 Querying Links</b></p></div>
            

            <pre class="programlisting brush: php">
$simpy = new Zend_Service_Simpy(&#039;yourusername&#039;, &#039;yourpassword&#039;);

/* Search for the 10 links added most recently */
$linkQuery = new Zend_Service_Simpy_LinkQuery();
$linkQuery-&gt;setLimit(10);

/* Get and display the links */
$linkSet = $simpy-&gt;getLinks($linkQuery);
foreach ($linkSet as $link) {
    echo &#039;&lt;a href=&quot;&#039;;
    echo $link-&gt;getUrl();
    echo &#039;&quot;&gt;&#039;;
    echo $link-&gt;getTitle();
    echo &#039;&lt;/a&gt;&lt;br /&gt;&#039;;
}

/* Search for the 5 links added most recently with &#039;PHP&#039; in
the title */
$linkQuery-&gt;setQueryString(&#039;title:PHP&#039;);
$linkQuery-&gt;setLimit(5);

/* Search for all links with &#039;French&#039; in the title and
&#039;language&#039; in the tags */
$linkQuery-&gt;setQueryString(&#039;+title:French +tags:language&#039;);

/* Search for all links with &#039;French&#039; in the title and without
&#039;travel&#039; in the tags */
$linkQuery-&gt;setQueryString(&#039;+title:French -tags:travel&#039;);

/* Search for all links added on 12/9/06 */
$linkQuery-&gt;setDate(&#039;2006-12-09&#039;);

/* Search for all links added after 12/9/06 (excluding that
date) */
$linkQuery-&gt;setAfterDate(&#039;2006-12-09&#039;);

/* Search for all links added before 12/9/06 (excluding that
date) */
$linkQuery-&gt;setBeforeDate(&#039;2006-12-09&#039;);

/* Search for all links added between 12/1/06 and 12/9/06
(excluding those two dates) */
$linkQuery-&gt;setBeforeDate(&#039;2006-12-01&#039;);
$linkQuery-&gt;setAfterDate(&#039;2006-12-09&#039;);
</pre>

        </div>

        <p class="para">
            Links are represented uniquely by their <acronym class="acronym">URL</acronym>s. In other words, if an
            attempt is made to save a link that has the same <acronym class="acronym">URL</acronym> as an existing
            link, data for the existing link will be overwritten with the data specified in the save
            attempt.
        </p>

        <div class="example" id="zend.service.simpy.links.modifying"><div class="info"><p><b>Example #2 Modifying Links</b></p></div>
            

            <pre class="programlisting brush: php">
$simpy = new Zend_Service_Simpy(&#039;yourusername&#039;, &#039;yourpassword&#039;);

/* Save a link */
$simpy-&gt;saveLink(
    &#039;Zend Framework&#039; // Title
    &#039;http://framework.zend.com&#039;, // URL
    Zend_Service_Simpy_Link::ACCESSTYPE_PUBLIC, // Access Type
    &#039;zend, framework, php&#039; // Tags
    &#039;Zend Framework home page&#039; // Alternative title
    &#039;This site rocks!&#039; // Note
);

/* Overwrite the existing link with new data */
$simpy-&gt;saveLink(
    &#039;Zend Framework&#039;
    &#039;http://framework.zend.com&#039;,
    Zend_Service_Simpy_Link::ACCESSTYPE_PRIVATE, // Access Type has changed
    &#039;php, zend, framework&#039; // Tags have changed order
    &#039;Zend Framework&#039; // Alternative title has changed
    &#039;This site REALLY rocks!&#039; // Note has changed
);

/* Delete the link */
$simpy-&gt;deleteLink(&#039;http://framework.zend.com&#039;);

/* A really easy way to do spring cleaning on your links ;) */
$linkSet = $this-&gt;_simpy-&gt;getLinks();
foreach ($linkSet as $link) {
    $this-&gt;_simpy-&gt;deleteLink($link-&gt;getUrl());
}
</pre>

        </div>
    </div>

    <div class="section" id="zend.service.simpy.tags"><div class="info"><h1 class="title">Tags</h1></div>
        

        <p class="para">
            When retrieved, tags are sorted in decreasing order (i.e. highest
            first) by the number of links that use the tag.
        </p>

        <div class="example" id="zend.service.simpy.tags.working"><div class="info"><p><b>Example #3 Working With Tags</b></p></div>
            

            <pre class="programlisting brush: php">
$simpy = new Zend_Service_Simpy(&#039;yourusername&#039;, &#039;yourpassword&#039;);

/* Save a link with tags */
$simpy-&gt;saveLink(
    &#039;Zend Framework&#039; // Title
    &#039;http://framework.zend.com&#039;, // URL
    Zend_Service_Simpy_Link::ACCESSTYPE_PUBLIC, // Access Type
    &#039;zend, framework, php&#039; // Tags
);

/* Get a list of all tags in use by links and notes */
$tagSet = $simpy-&gt;getTags();

/* Display each tag with the number of links using it */
foreach ($tagSet as $tag) {
    echo $tag-&gt;getTag();
    echo &#039; - &#039;;
    echo $tag-&gt;getCount();
    echo &#039;&lt;br /&gt;&#039;;
}

/* Remove the &#039;zend&#039; tag from all links using it */
$simpy-&gt;removeTag(&#039;zend&#039;);

/* Rename the &#039;framework&#039; tag to &#039;frameworks&#039; */
$simpy-&gt;renameTag(&#039;framework&#039;, &#039;frameworks&#039;);

/* Split the &#039;frameworks&#039; tag into &#039;framework&#039; and
&#039;development&#039;, which will remove the &#039;frameworks&#039; tag for
all links that use it and add the tags &#039;framework&#039; and
&#039;development&#039; to all of those links */
$simpy-&gt;splitTag(&#039;frameworks&#039;, &#039;framework&#039;, &#039;development&#039;);

/* Merge the &#039;framework&#039; and &#039;development&#039; tags back into
&#039;frameworks&#039;, basically doing the opposite of splitting them */
$simpy-&gt;mergeTags(&#039;framework&#039;, &#039;development&#039;, &#039;frameworks&#039;);
</pre>

        </div>
    </div>

    <div class="section" id="zend.service.simpy.notes"><div class="info"><h1 class="title">Notes</h1></div>
        

        <p class="para">
            Notes can be saved, retrieved, and deleted. They are uniquely
            identified by a numeric ID value.
        </p>

        <div class="example" id="zend.service.simpy.notes.working"><div class="info"><p><b>Example #4 Working With Notes</b></p></div>
            

            <pre class="programlisting brush: php">
$simpy = new Zend_Service_Simpy(&#039;yourusername&#039;, &#039;yourpassword&#039;);

/* Save a note */
$simpy-&gt;saveNote(
    &#039;Test Note&#039;, // Title
    &#039;test,note&#039;, // Tags
    &#039;This is a test note.&#039; // Description
);

/* Overwrite an existing note */
$simpy-&gt;saveNote(
    &#039;Updated Test Note&#039;, // Title
    &#039;test,note,updated&#039;, // Tags
    &#039;This is an updated test note.&#039;, // Description
    $note-&gt;getId() // Unique identifier
);

/* Search for the 10 most recently added notes */
$noteSet = $simpy-&gt;getNotes(null, 10);

/* Display the notes */
foreach ($noteSet as $note) {
    echo &#039;&lt;p&gt;&#039;;
    echo $note-&gt;getTitle();
    echo &#039;&lt;br /&gt;&#039;;
    echo $note-&gt;getDescription();
    echo &#039;&lt;br &gt;&#039;;
    echo $note-&gt;getTags();
    echo &#039;&lt;/p&gt;&#039;;
}

/* Search for all notes with &#039;PHP&#039; in the title */
$noteSet = $simpy-&gt;getNotes(&#039;title:PHP&#039;);

/* Search for all notes with &#039;PHP&#039; in the title and
without &#039;framework&#039; in the description */
$noteSet = $simpy-&gt;getNotes(&#039;+title:PHP -description:framework&#039;);

/* Delete a note */
$simpy-&gt;deleteNote($note-&gt;getId());
</pre>

        </div>
    </div>

    <div class="section" id="zend.service.simpy.watchlists"><div class="info"><h1 class="title">Watchlists</h1></div>
        

        <p class="para">
            Watchlists cannot be created or removed using the <acronym class="acronym">API</acronym>, only
            retrieved. Thus, you must set up a watchlist via the Simpy web
            site prior to attempting to access it using the <acronym class="acronym">API</acronym>.
        </p>

        <div class="example" id="zend.service.simpy.watchlists.retrieving"><div class="info"><p><b>Example #5 Retrieving Watchlists</b></p></div>
            

            <pre class="programlisting brush: php">
$simpy = new Zend_Service_Simpy(&#039;yourusername&#039;, &#039;yourpassword&#039;);

/* Get a list of all watchlists */
$watchlistSet = $simpy-&gt;getWatchlists();

/* Display data for each watchlist */
foreach ($watchlistSet as $watchlist) {
    echo $watchlist-&gt;getId();
    echo &#039;&lt;br /&gt;&#039;;
    echo $watchlist-&gt;getName();
    echo &#039;&lt;br /&gt;&#039;;
    echo $watchlist-&gt;getDescription();
    echo &#039;&lt;br /&gt;&#039;;
    echo $watchlist-&gt;getAddDate();
    echo &#039;&lt;br /&gt;&#039;;
    echo $watchlist-&gt;getNewLinks();
    echo &#039;&lt;br /&gt;&#039;;

    foreach ($watchlist-&gt;getUsers() as $user) {
        echo $user;
        echo &#039;&lt;br /&gt;&#039;;
    }

    foreach ($watchlist-&gt;getFilters() as $filter) {
        echo $filter-&gt;getName();
        echo &#039;&lt;br /&gt;&#039;;
        echo $filter-&gt;getQuery();
        echo &#039;&lt;br /&gt;&#039;;
    }
}

/* Get an individual watchlist by its identifier */
$watchlist = $simpy-&gt;getWatchlist($watchlist-&gt;getId());
$watchlist = $simpy-&gt;getWatchlist(1);
</pre>

        </div>
    </div>
</div>
        <hr />

            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.service.short-url.html">Zend_Service_ShortUrl</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.service.html">Zend_Service</a></span><br />
                        <span class="home"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.service.slideshare.html">Zend_Service_SlideShare</a></div>
                    </td>
                </tr>
            </table>
</td>
        <td style="font-size: smaller;" width="15%"> <style type="text/css">
#leftbar {
	float: left;
	width: 186px;
	padding: 5px;
	font-size: smaller;
}
ul.toc {
	margin: 0px 5px 5px 5px;
	padding: 0px;
}
ul.toc li {
	font-size: 85%;
	margin: 1px 0 1px 1px;
	padding: 1px 0 1px 11px;
	list-style-type: none;
	background-repeat: no-repeat;
	background-position: center left;
}
ul.toc li.header {
	font-size: 115%;
	padding: 5px 0px 5px 11px;
	border-bottom: 1px solid #cccccc;
	margin-bottom: 5px;
}
ul.toc li.active {
	font-weight: bold;
}
ul.toc li a {
	text-decoration: none;
}
ul.toc li a:hover {
	text-decoration: underline;
}
</style>
 <ul class="toc">
  <li class="header home"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></li>
  <li class="header up"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></li>
  <li class="header up"><a href="reference.html">Refer&ecirc;ncia do Zend Framework</a></li>
  <li class="header up"><a href="zend.service.html">Zend_Service</a></li>
  <li><a href="zend.service.introduction.html">Introdu&ccedil;&atilde;o</a></li>
  <li><a href="zend.service.akismet.html">Zend_Service_Akismet</a></li>
  <li><a href="zend.service.amazon.html">Zend_Service_Amazon</a></li>
  <li><a href="zend.service.amazon.ec2.html">Zend_Service_Amazon_Ec2</a></li>
  <li><a href="zend.service.amazon.ec2.instance.html">Zend_Service_Amazon_Ec2: Instances</a></li>
  <li><a href="zend.service.amazon.ec2.windows.instance.html">Zend_Service_Amazon_Ec2: Windows Instances</a></li>
  <li><a href="zend.service.amazon.ec2.reserved.instance.html">Zend_Service_Amazon_Ec2: Reserved Instances</a></li>
  <li><a href="zend.service.amazon.ec2.cloudwatch.html">Zend_Service_Amazon_Ec2: CloudWatch Monitoring</a></li>
  <li><a href="zend.service.amazon.ec2.images.html">Zend_Service_Amazon_Ec2: Amazon Machine Images (AMI)</a></li>
  <li><a href="zend.service.amazon.ec2.ebs.html">Zend_Service_Amazon_Ec2: Elastic Block Storage (EBS)</a></li>
  <li><a href="zend.service.amazon.ec2.elasticip.html">Zend_Service_Amazon_Ec2: Elastic IP Addresses</a></li>
  <li><a href="zend.service.amazon.ec2.keypairs.html">Zend_Service_Amazon_Ec2: Keypairs</a></li>
  <li><a href="zend.service.amazon.ec2.zones.html">Zend_Service_Amazon_Ec2: Regions and Availability Zones</a></li>
  <li><a href="zend.service.amazon.ec2.securitygroups.html">Zend_Service_Amazon_Ec2: Security Groups</a></li>
  <li><a href="zend.service.amazon.s3.html">Zend_Service_Amazon_S3</a></li>
  <li><a href="zend.service.amazon.sqs.html">Zend_Service_Amazon_Sqs</a></li>
  <li><a href="zend.service.audioscrobbler.html">Zend_Service_Audioscrobbler</a></li>
  <li><a href="zend.service.delicious.html">Zend_Service_Delicious</a></li>
  <li><a href="zend.service.developergarden.html">Zend_Service_DeveloperGarden</a></li>
  <li><a href="zend.service.ebay.html">Zend_Service_Ebay</a></li>
  <li><a href="zend.service.ebay.finding.html">Zend_Service_Ebay_Finding</a></li>
  <li><a href="zend.service.flickr.html">Zend_Service_Flickr</a></li>
  <li><a href="zend.service.livedocx.html">Zend_Service_LiveDocx</a></li>
  <li><a href="zend.service.nirvanix.html">Zend_Service_Nirvanix</a></li>
  <li><a href="zend.service.recaptcha.html">Zend_Service_ReCaptcha</a></li>
  <li><a href="zend.service.short-url.html">Zend_Service_ShortUrl</a></li>
  <li class="active"><a href="zend.service.simpy.html">Zend_Service_Simpy</a></li>
  <li><a href="zend.service.slideshare.html">Zend_Service_SlideShare</a></li>
  <li><a href="zend.service.strikeiron.html">Zend_Service_StrikeIron</a></li>
  <li><a href="zend.service.strikeiron.bundled-services.html">Zend_Service_StrikeIron: Bundled Services</a></li>
  <li><a href="zend.service.strikeiron.advanced-uses.html">Zend_Service_StrikeIron: Advanced Uses</a></li>
  <li><a href="zend.service.technorati.html">Zend_Service_Technorati</a></li>
  <li><a href="zend.service.twitter.html">Zend_Service_Twitter</a></li>
  <li><a href="zend.service.windowsazure.html">Zend_Service_WindowsAzure</a></li>
  <li><a href="zend.service.windowsazure.storage.blob.html">Zend_Service_WindowsAzure_Storage_Blob</a></li>
  <li><a href="zend.service.windowsazure.diagnostics.manager.html">Zend_Service_WindowsAzure_Diagnostics_Manager</a></li>
  <li><a href="zend.service.windowsazure.storage.queue.html">Zend_Service_WindowsAzure_Storage_Queue</a></li>
  <li><a href="zend.service.windowsazure.storage.table.html">Zend_Service_WindowsAzure_Storage_Table</a></li>
  <li><a href="zend.service.yahoo.html">Zend_Service_Yahoo</a></li>
 </ul>
 </td>
    </tr>
</table>

<script type="text/javascript" src="../js/shCore.js"></script>
<script type="text/javascript" src="../js/shAutoloader.js"></script>
<script type="text/javascript" src="../js/main.js"></script>

</body>
</html>